package learn.ch1.pool;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Description todo
 * @Author yusj
 * @Date 2021/12/13
 * @Version 1.0
 */
public class Call01 implements Callable<String> {
    @Override
    public String call() throws Exception {
        Thread.sleep(2000);
        System.out.println("over");
        return "success";
    }

    public static void main(String[] args) {
        Callable callable=new Call01();
        FutureTask  task=new FutureTask(callable);
        new Thread(task).start();
        try {
            System.out.println("over1");
            task.get();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }

    }
}
